<%-- 
    Document   : ThemLoaiDM
    Created on : Oct 18, 2011, 9:59:05 PM
    Author     : kijoo
--%>

<%@page import="MODEL.POJO.LoaiDanhMucPOJO"%>
<%@page import="MODEL.POJO.LoaiSanPhamPOJO"%>
<%@page import="MODEL.DAO.LoaiSanPhamDAO"%>
<%@page import="MODEL.DAO.LoaiDanhMucDAO"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.util.ArrayList"%>
<style type="text/css">
    <!--
    .style1 {color: #000000}
    -->
</style>
<div class="tieude">Thêm loại danh mục</div>
<div align="center">
    <form  onSubmit="return kiemtra()" action="ThemLoaiDanhMucController?Action=Insert" method="post" name="form1" id="them">
        <table width="505" height="139" align="center">   
            <tr>
            <td width="161" height="28"><label><span style="color: #000000">Chọn loại sản phẩm</span></label></td>
            <td width="332"><label for="loaiSP"></label>
            <select name="loaiSP" id="loaiSP">
                <option value="-1">--Chọn loại sản phẩm--</option>
                <%

                    ArrayList<LoaiSanPhamPOJO> ds = LoaiSanPhamDAO.LayDanhSachLoaiSanPham();
                    for (int i = 0; i < ds.size(); i++) {
                        LoaiSanPhamPOJO lsp = ds.get(i);

                %>
                <option value="<%=lsp.getIdloaisanpham()%>" 
                        <%
                            if (request.getParameter("loaiSP") != null) {
                                String danhMuc = request.getParameter("loaiSP");

                                if (danhMuc.equals(lsp.getIdloaisanpham())) {
                        %>
                        selected="selected"
                        <%}
                                }%>
                        ><%=lsp.getTenloaisanpham()%></option>
                <%}%>
            </select></td>
            </tr>

            <tr>
            <td height="24"><label><span style="color: #000000">Mã loại danh mục</span></label></td>
            <td><label for="maLoaiDM"></label>
            <input type="text" name="maLoaiDM" id="maLoaiDM" size="50"
                   <%
                       if (request.getParameter("maLoaiDM") != null) {
                   %>
                   value="<%=request.getParameter("maLoaiDM")%>"
                   <%}%>                       />
            </td>
            </tr>
            <tr>
            <td height="29"><label><span style="color: #000000">Tên loại danh mục</span></label></td>
            <td><label for="tenLoaiDM"></label>
            <input type="text" name="tenLoaiDM" id="tenLoaiDM" size="50"
                   <%
                       if (request.getParameter("tenLoaiDM") != null) {
                   %>
                   value="<%=request.getParameter("tenLoaiDM")%>"
                   <%}%>                       />
            </td>
            </tr>


            <tr>
            <td colspan="2"><div align="center">
                    <input type="submit" name="Them" id="Them" value="Thêm" style="background-color:#FFFF66">
                    <input type="hidden" name="Action" value="Insert"/>
                </div></td>
            </tr>
      </table>
    </form>
</div>
<script language="JavaScript">
    function kiemtra()
    {
        form1=document.getElementById("them");
        if(form1.loaiSP.value=="-1")
        {
            alert("Chưa chọn loại sản phẩm"); form1.loaiSP.focus(); return false; 
        }
        if(form1.maLoaiDM.value=="")
        {
            alert("Chưa nhập mã loại danh mục"); form1.maLoaiDM.focus(); return false; 
        }
        if(form1.tenLoaiDM.value=="")
        {
            alert("Chưa nhập tên loại danh mục"); form1.tenLoaiDM.focus(); return false; 
        }
        return true;
    }
</script> 

